package threading;

import java.util.Scanner;

/**
 * @author krystal
 * @date 2022/11/23 22:10
 */

public class Demo16 {
    static class Counter{
        volatile public int count=0;
    }

    public static void main(String[] args) {
        Counter counter=new Counter();
        Thread t1=new Thread(()->{
            while (counter.count==0){

            }
            System.out.println("t1执行结束");
        });
        t1.start();

        Thread t2=new Thread(()->{
            System.out.println("请输入一个int：");
            Scanner scanner=new Scanner(System.in);
            counter.count=scanner.nextInt();
        });
        t2.start();
    }
}
